source("dados_playoffs.R")
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ lubridate 1.9.3     ✔ tibble    3.2.1
## ✔ purrr     1.0.2     ✔ tidyr     1.3.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
## Loading required package: splines
## 
## Loading required package: gamlss.data
## 
## 
## Attaching package: 'gamlss.data'
## 
## 
## The following object is masked from 'package:datasets':
## 
##     sleep
## 
## 
## Loading required package: gamlss.dist
## 
## Loading required package: nlme
## 
## 
## Attaching package: 'nlme'
## 
## 
## The following object is masked from 'package:dplyr':
## 
##     collapse
## 
## 
## Loading required package: parallel
## 
##  **********   GAMLSS Version 5.4-22  ********** 
## 
## For more on GAMLSS look at https://www.gamlss.com/
## 
## Type gamlssNews() to see new features/changes/bug fixes.
## 
## 
## Loading required package: carData
## 
## 
## Attaching package: 'car'
## 
## 
## The following object is masked from 'package:dplyr':
## 
##     recode
## 
## 
## The following object is masked from 'package:purrr':
## 
##     some
## 
## 
## Loading required package: zoo
## 
## 
## Attaching package: 'zoo'
## 
## 
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
######### Regressão linear ########
modelo_forwp <- lm(formula = WINP ~ PlusMinus + DREB, data = dados_regressaop)
modelo_forwp
## 
## Call:
## lm(formula = WINP ~ PlusMinus + DREB, data = dados_regressaop)
## 
## Coefficients:
## (Intercept)    PlusMinus         DREB  
##    0.345213     0.025682     0.004033
coef(modelo_forwp)
## (Intercept)   PlusMinus        DREB 
## 0.345212858 0.025681939 0.004033267
anova(modelo_forwp)
## Analysis of Variance Table
## 
## Response: WINP
##            Df Sum Sq Mean Sq  F value  Pr(>F)    
## PlusMinus   1 7.3972  7.3972 681.7284 < 2e-16 ***
## DREB        1 0.0299  0.0299   2.7587 0.09805 .  
## Residuals 237 2.5716  0.0109                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(modelo_forwp) #Adjusted R-squared:  0.7406 
## 
## Call:
## lm(formula = WINP ~ PlusMinus + DREB, data = dados_regressaop)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.36469 -0.05721  0.01300  0.07160  0.36417 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 0.345213   0.078459   4.400 1.64e-05 ***
## PlusMinus   0.025682   0.001049  24.490  < 2e-16 ***
## DREB        0.004033   0.002428   1.661    0.098 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1042 on 237 degrees of freedom
## Multiple R-squared:  0.7428, Adjusted R-squared:  0.7406 
## F-statistic: 342.2 on 2 and 237 DF,  p-value: < 2.2e-16
AIC(modelo_forwp)
## [1] -399.576
#### Resíduos Forward ###
plot(modelo_forwp, which = 1)

plot(modelo_forwp, which = 2)

plot(modelo_forwp, which = 3)

plot(modelo_forwp, which = 4)

plot(modelo_forwp, which = 5)

plot(modelo_forwp, which = 6)

shapiro.test(modelo_forwp$residuals) #p-value = 0.1997, normal
## 
##  Shapiro-Wilk normality test
## 
## data:  modelo_forwp$residuals
## W = 0.96952, p-value = 5.082e-05
#Teste de durbin watson para independencia
library(lmtest)
dwtest(modelo_forwp) #p-value = 0.07378
## 
##  Durbin-Watson test
## 
## data:  modelo_forwp
## DW = 1.8195, p-value = 0.07378
## alternative hypothesis: true autocorrelation is greater than 0
#Independência
plot(modelo_forwp$residuals,
     ylab = "Residuos",
     xlab = "Index dos Imovéis", 
     main = "Suposição de independência",
     pch = 19)

#Homocedasticidade
plot(modelo_forwp$fitted.values, modelo_forwp$residuals, 
     xlab = "Valores Ajustados",
     ylab = "Residuos",
     pch = 19,
     main = "Suposição de homocedasticidade"
)

#Breusch_Pagan para homocedasticdade
bptest(modelo_forwp) #p-value = 1.981e-05, heterocedasticidade
## 
##  studentized Breusch-Pagan test
## 
## data:  modelo_forwp
## BP = 21.659, df = 2, p-value = 1.981e-05
######## Betareg #######
### Logito #####
modelo_betapt_ftp <- betareg(formula = WINP_transformado ~ FTP + REB + PlusMinus, data = playoffs_transformado)
modelo_betapt_ftp
## 
## Call:
## betareg(formula = WINP_transformado ~ FTP + REB + PlusMinus, data = playoffs_transformado)
## 
## Coefficients (mean model with logit link):
## (Intercept)          FTP          REB    PlusMinus  
##    -2.70112      0.01822      0.02605      0.14844  
## 
## Phi coefficients (precision model with identity link):
## (phi)  
## 8.628
summary(modelo_betapt_ftp)
## 
## Call:
## betareg(formula = WINP_transformado ~ FTP + REB + PlusMinus, data = playoffs_transformado)
## 
## Standardized weighted residuals 2:
##     Min      1Q  Median      3Q     Max 
## -6.6072 -0.2417  0.2460  0.6519  1.5089 
## 
## Coefficients (mean model with logit link):
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept) -2.701118   0.960492  -2.812  0.00492 ** 
## FTP          0.018224   0.009515   1.915  0.05546 .  
## REB          0.026050   0.013738   1.896  0.05793 .  
## PlusMinus    0.148440   0.008141  18.233  < 2e-16 ***
## 
## Phi coefficients (precision model with identity link):
##       Estimate Std. Error z value Pr(>|z|)    
## (phi)   8.6276     0.7677   11.24   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
## 
## Type of estimator: ML (maximum likelihood)
## Log-likelihood: 168.6 on 5 Df
## Pseudo R-squared: 0.5202
## Number of iterations: 18 (BFGS) + 3 (Fisher scoring)
car::Anova(modelo_betapt_ftp)
## Analysis of Deviance Table (Type II tests)
## 
## Response: WINP_transformado
##           Df    Chisq Pr(>Chisq)    
## FTP        1   3.6683    0.05546 .  
## REB        1   3.5957    0.05793 .  
## PlusMinus  1 332.4251    < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
coef(modelo_betapt_ftp)
## (Intercept)         FTP         REB   PlusMinus       (phi) 
## -2.70111757  0.01822447  0.02605043  0.14844007  8.62758070
# Resíduos logito #
plot(modelo_betapt_ftp, which = 1)

plot(modelo_betapt_ftp, which = 2)

plot(modelo_betapt_ftp, which = 3)

plot(modelo_betapt_ftp, which = 4)

plot(modelo_betapt_ftp, which = 5) #QQplot não foi muito bom

plot(modelo_betapt_ftp, which = 6)

shapiro.test(modelo_betapt_ftp$residuals) #p-value = 0.7859, normal
## 
##  Shapiro-Wilk normality test
## 
## data:  modelo_betapt_ftp$residuals
## W = 0.99086, p-value = 0.1381
#Teste de durbin watson para independencia
library(lmtest)
dwtest(modelo_betapt_ftp) #p-value = 0.05838
## 
##  Durbin-Watson test
## 
## data:  modelo_betapt_ftp
## DW = 1.8033, p-value = 0.05838
## alternative hypothesis: true autocorrelation is greater than 0
#Independência
plot(modelo_betapt_ftp$residuals,
     ylab = "Residuos",
     xlab = "Index dos Imovéis", 
     main = "Suposição de independência",
     pch = 19)

#Homocedasticidade
plot(modelo_betapt_ftp$fitted.values, modelo_betapt_ftp$residuals, 
     xlab = "Valores Ajustados",
     ylab = "Residuos",
     pch = 19,
     main = "Suposição de homocedasticidade"
)

#Breusch_Pagan para homocedasticdade
bptest(modelo_betapt_ftp) #p-value = 0.0001505 heterocedasticidade
## 
##  studentized Breusch-Pagan test
## 
## data:  modelo_betapt_ftp
## BP = 20.252, df = 3, p-value = 0.0001505
### loglog ####
modelop_loglog_reb <- betareg(formula = WINP_transformado ~ REB + PlusMinus, data = playoffs_transformado,link = "loglog") 
modelop_loglog_reb
## 
## Call:
## betareg(formula = WINP_transformado ~ REB + PlusMinus, data = playoffs_transformado, 
##     link = "loglog")
## 
## Coefficients (mean model with loglog link):
## (Intercept)          REB    PlusMinus  
##    -0.64302      0.02108      0.08192  
## 
## Phi coefficients (precision model with identity link):
## (phi)  
## 8.439
summary(modelop_loglog_reb)
## 
## Call:
## betareg(formula = WINP_transformado ~ REB + PlusMinus, data = playoffs_transformado, 
##     link = "loglog")
## 
## Standardized weighted residuals 2:
##     Min      1Q  Median      3Q     Max 
## -6.8898 -0.1969  0.2649  0.6177  1.5457 
## 
## Coefficients (mean model with loglog link):
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept) -0.643022   0.325933  -1.973  0.04851 *  
## REB          0.021083   0.007695   2.740  0.00615 ** 
## PlusMinus    0.081916   0.003444  23.784  < 2e-16 ***
## 
## Phi coefficients (precision model with identity link):
##       Estimate Std. Error z value Pr(>|z|)    
## (phi)   8.4390     0.7512   11.23   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
## 
## Type of estimator: ML (maximum likelihood)
## Log-likelihood: 162.3 on 4 Df
## Pseudo R-squared: 0.6689
## Number of iterations: 15 (BFGS) + 1 (Fisher scoring)
car::Anova(modelop_loglog_reb)
## Analysis of Deviance Table (Type II tests)
## 
## Response: WINP_transformado
##           Df    Chisq Pr(>Chisq)    
## REB        1   7.5065   0.006148 ** 
## PlusMinus  1 565.6606  < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
coef(modelop_loglog_reb)
## (Intercept)         REB   PlusMinus       (phi) 
## -0.64302232  0.02108259  0.08191571  8.43898300
# Resíduos logito #
plot(modelop_loglog_reb, which = 1)

plot(modelop_loglog_reb, which = 2)

plot(modelop_loglog_reb, which = 3)

plot(modelop_loglog_reb, which = 4)

plot(modelop_loglog_reb, which = 5) #QQplot não foi muito bom

plot(modelop_loglog_reb, which = 6)

shapiro.test(modelop_loglog_reb$residuals) #p-value = 0.005181, normal
## 
##  Shapiro-Wilk normality test
## 
## data:  modelop_loglog_reb$residuals
## W = 0.98276, p-value = 0.005181
#Teste de durbin watson para independencia
library(lmtest)
dwtest(modelop_loglog_reb) #p-value = 0.07596
## 
##  Durbin-Watson test
## 
## data:  modelop_loglog_reb
## DW = 1.8197, p-value = 0.07596
## alternative hypothesis: true autocorrelation is greater than 0
#Independência
plot(modelop_loglog_reb$residuals,
     ylab = "Residuos",
     xlab = "Index dos Imovéis", 
     main = "Suposição de independência",
     pch = 19)

#Homocedasticidade
plot(modelop_loglog_reb$fitted.values, modelop_loglog_reb$residuals, 
     xlab = "Valores Ajustados",
     ylab = "Residuos",
     pch = 19,
     main = "Suposição de homocedasticidade"
)

#Breusch_Pagan para homocedasticdade
bptest(modelop_loglog_reb) #p-value = 4.637e-05 heterocedasticidade
## 
##  studentized Breusch-Pagan test
## 
## data:  modelop_loglog_reb
## BP = 19.958, df = 2, p-value = 4.637e-05
### Probito #####
modelop_probit_ftp <- betareg(formula = WINP_transformado ~ FTP + REB + PlusMinus, data = playoffs_transformado, 
                              link = "probit")
modelop_probit_ftp
## 
## Call:
## betareg(formula = WINP_transformado ~ FTP + REB + PlusMinus, data = playoffs_transformado, 
##     link = "probit")
## 
## Coefficients (mean model with probit link):
## (Intercept)          FTP          REB    PlusMinus  
##    -1.61947      0.01013      0.01697      0.08691  
## 
## Phi coefficients (precision model with identity link):
## (phi)  
## 8.695
summary(modelop_probit_ftp)
## 
## Call:
## betareg(formula = WINP_transformado ~ FTP + REB + PlusMinus, data = playoffs_transformado, 
##     link = "probit")
## 
## Standardized weighted residuals 2:
##     Min      1Q  Median      3Q     Max 
## -6.7399 -0.2532  0.2570  0.6393  1.5064 
## 
## Coefficients (mean model with probit link):
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept) -1.619472   0.557171  -2.907  0.00365 ** 
## FTP          0.010132   0.005527   1.833  0.06679 .  
## REB          0.016972   0.008038   2.111  0.03475 *  
## PlusMinus    0.086908   0.004332  20.061  < 2e-16 ***
## 
## Phi coefficients (precision model with identity link):
##       Estimate Std. Error z value Pr(>|z|)    
## (phi)   8.6950     0.7759   11.21   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
## 
## Type of estimator: ML (maximum likelihood)
## Log-likelihood: 168.2 on 5 Df
## Pseudo R-squared: 0.5897
## Number of iterations: 18 (BFGS) + 2 (Fisher scoring)
car::Anova(modelop_probit_ftp)
## Analysis of Deviance Table (Type II tests)
## 
## Response: WINP_transformado
##           Df    Chisq Pr(>Chisq)    
## FTP        1   3.3603    0.06679 .  
## REB        1   4.4576    0.03475 *  
## PlusMinus  1 402.4243    < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
coef(modelop_probit_ftp)
## (Intercept)         FTP         REB   PlusMinus       (phi) 
## -1.61947183  0.01013154  0.01697157  0.08690779  8.69502494
# Resíduos logito #
plot(modelop_probit_ftp, which = 1)

plot(modelop_probit_ftp, which = 2)

plot(modelop_probit_ftp, which = 3)

plot(modelop_probit_ftp, which = 4)

plot(modelop_probit_ftp, which = 5) #QQplot não foi muito bom

plot(modelop_probit_ftp, which = 6)

shapiro.test(modelop_probit_ftp$residuals) #p-value = 0.08389, normal
## 
##  Shapiro-Wilk normality test
## 
## data:  modelop_probit_ftp$residuals
## W = 0.98965, p-value = 0.08389
#Teste de durbin watson para independencia
library(lmtest)
dwtest(modelop_probit_ftp) #p-value = 0.05838
## 
##  Durbin-Watson test
## 
## data:  modelop_probit_ftp
## DW = 1.8033, p-value = 0.05838
## alternative hypothesis: true autocorrelation is greater than 0
#Independência
plot(modelop_probit_ftp$residuals,
     ylab = "Residuos",
     xlab = "Index dos Imovéis", 
     main = "Suposição de independência",
     pch = 19)

#Homocedasticidade
plot(modelop_probit_ftp$fitted.values, modelop_probit_ftp$residuals, 
     xlab = "Valores Ajustados",
     ylab = "Residuos",
     pch = 19,
     main = "Suposição de homocedasticidade"
)

#Breusch_Pagan para homocedasticdade
bptest(modelop_probit_ftp) #p-value = 0.0001505 heterocedasticidade
## 
##  studentized Breusch-Pagan test
## 
## data:  modelop_probit_ftp
## BP = 20.252, df = 3, p-value = 0.0001505
### cloglog ####
modelo_betat_cloglog_ftp <- betareg(formula = WINP_transformado ~ FTP + REB + PlusMinus, data = playoffs_transformado, 
                                    link = "cloglog")
modelo_betat_cloglog_ftp
## 
## Call:
## betareg(formula = WINP_transformado ~ FTP + REB + PlusMinus, data = playoffs_transformado, 
##     link = "cloglog")
## 
## Coefficients (mean model with cloglog link):
## (Intercept)          FTP          REB    PlusMinus  
##    -2.51458      0.01496      0.01872      0.11192  
## 
## Phi coefficients (precision model with identity link):
## (phi)  
## 8.037
summary(modelo_betat_cloglog_ftp)
## 
## Call:
## betareg(formula = WINP_transformado ~ FTP + REB + PlusMinus, data = playoffs_transformado, 
##     link = "cloglog")
## 
## Standardized weighted residuals 2:
##     Min      1Q  Median      3Q     Max 
## -6.2025 -0.2494  0.3180  0.7076  1.4128 
## 
## Coefficients (mean model with cloglog link):
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept) -2.514577   0.766704  -3.280  0.00104 ** 
## FTP          0.014962   0.007520   1.989  0.04665 *  
## REB          0.018717   0.010768   1.738  0.08218 .  
## PlusMinus    0.111920   0.006211  18.021  < 2e-16 ***
## 
## Phi coefficients (precision model with identity link):
##       Estimate Std. Error z value Pr(>|z|)    
## (phi)   8.0370     0.7113    11.3   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
## 
## Type of estimator: ML (maximum likelihood)
## Log-likelihood: 162.2 on 5 Df
## Pseudo R-squared: 0.4689
## Number of iterations: 19 (BFGS) + 1 (Fisher scoring)
car::Anova(modelo_betat_cloglog_ftp)
## Analysis of Deviance Table (Type II tests)
## 
## Response: WINP_transformado
##           Df    Chisq Pr(>Chisq)    
## FTP        1   3.9579    0.04665 *  
## REB        1   3.0212    0.08218 .  
## PlusMinus  1 324.7531    < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
coef(modelo_betat_cloglog_ftp)
## (Intercept)         FTP         REB   PlusMinus       (phi) 
## -2.51457700  0.01496152  0.01871662  0.11191991  8.03696860
# Resíduos logito #
plot(modelo_betat_cloglog_ftp, which = 1)

plot(modelo_betat_cloglog_ftp, which = 2)

plot(modelo_betat_cloglog_ftp, which = 3)

plot(modelo_betat_cloglog_ftp, which = 4)

plot(modelo_betat_cloglog_ftp, which = 5) #QQplot não foi muito bom

plot(modelo_betat_cloglog_ftp, which = 6)

shapiro.test(modelo_betat_cloglog_ftp$residuals) #p-value = 0.08389, normal
## 
##  Shapiro-Wilk normality test
## 
## data:  modelo_betat_cloglog_ftp$residuals
## W = 0.987, p-value = 0.02824
#Teste de durbin watson para independencia
library(lmtest)
dwtest(modelo_betat_cloglog_ftp) #p-value = 0.05838
## 
##  Durbin-Watson test
## 
## data:  modelo_betat_cloglog_ftp
## DW = 1.8033, p-value = 0.05838
## alternative hypothesis: true autocorrelation is greater than 0
#Independência
plot(modelo_betat_cloglog_ftp$residuals,
     ylab = "Residuos",
     xlab = "Index dos Imovéis", 
     main = "Suposição de independência",
     pch = 19)

#Homocedasticidade
plot(modelo_betat_cloglog_ftp$fitted.values, modelo_betat_cloglog_ftp$residuals, 
     xlab = "Valores Ajustados",
     ylab = "Residuos",
     pch = 19,
     main = "Suposição de homocedasticidade"
)

#Breusch_Pagan para homocedasticdade
bptest(modelo_betat_cloglog_ftp) #p-value = 0.0001505 heterocedasticidade
## 
##  studentized Breusch-Pagan test
## 
## data:  modelo_betat_cloglog_ftp
## BP = 20.252, df = 3, p-value = 0.0001505
### cauchito ####
modelo_betat_cauchit_ftp <- betareg(formula = WINP_transformado ~ FTP + PlusMinus, data = playoffs_transformado, 
                                    link = "cauchit")
modelo_betat_cauchit_ftp
## 
## Call:
## betareg(formula = WINP_transformado ~ FTP + PlusMinus, data = playoffs_transformado, 
##     link = "cauchit")
## 
## Coefficients (mean model with cauchit link):
## (Intercept)          FTP    PlusMinus  
##    -1.58499      0.01838      0.15092  
## 
## Phi coefficients (precision model with identity link):
## (phi)  
##  7.34
summary(modelo_betat_cauchit_ftp)
## 
## Call:
## betareg(formula = WINP_transformado ~ FTP + PlusMinus, data = playoffs_transformado, 
##     link = "cauchit")
## 
## Standardized weighted residuals 2:
##     Min      1Q  Median      3Q     Max 
## -5.7092 -0.3498  0.2333  0.6419  1.3118 
## 
## Coefficients (mean model with cauchit link):
##             Estimate Std. Error z value Pr(>|z|)    
## (Intercept) -1.58499    0.79614  -1.991   0.0465 *  
## FTP          0.01838    0.01033   1.780   0.0751 .  
## PlusMinus    0.15092    0.01172  12.882   <2e-16 ***
## 
## Phi coefficients (precision model with identity link):
##       Estimate Std. Error z value Pr(>|z|)    
## (phi)   7.3404     0.6427   11.42   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
## 
## Type of estimator: ML (maximum likelihood)
## Log-likelihood: 154.6 on 4 Df
## Pseudo R-squared: 0.2574
## Number of iterations: 60 (BFGS) + 2 (Fisher scoring)
car::Anova(modelo_betat_cauchit_ftp)
## Analysis of Deviance Table (Type II tests)
## 
## Response: WINP_transformado
##           Df    Chisq Pr(>Chisq)    
## FTP        1   3.1679     0.0751 .  
## PlusMinus  1 165.9406     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
coef(modelo_betat_cauchit_ftp)
## (Intercept)         FTP   PlusMinus       (phi) 
## -1.58499016  0.01838294  0.15091652  7.34042352
# Resíduos logito #
plot(modelo_betat_cauchit_ftp, which = 1)

plot(modelo_betat_cauchit_ftp, which = 2)

plot(modelo_betat_cauchit_ftp, which = 3)

plot(modelo_betat_cauchit_ftp, which = 4)

plot(modelo_betat_cauchit_ftp, which = 5) #QQplot não foi muito bom

plot(modelo_betat_cauchit_ftp, which = 6)

shapiro.test(modelo_betat_cauchit_ftp$residuals) #p-value = 0.05594, normal
## 
##  Shapiro-Wilk normality test
## 
## data:  modelo_betat_cauchit_ftp$residuals
## W = 0.98867, p-value = 0.05594
#Teste de durbin watson para independencia
library(lmtest)
dwtest(modelo_betat_cauchit_ftp) #p-value = 0.06737
## 
##  Durbin-Watson test
## 
## data:  modelo_betat_cauchit_ftp
## DW = 1.8122, p-value = 0.06737
## alternative hypothesis: true autocorrelation is greater than 0
#Independência
plot(modelo_betat_cauchit_ftp$residuals,
     ylab = "Residuos",
     xlab = "Index dos Imovéis", 
     main = "Suposição de independência",
     pch = 19)

#Homocedasticidade
plot(modelo_betat_cauchit_ftp$fitted.values, modelo_betat_cauchit_ftp$residuals, 
     xlab = "Valores Ajustados",
     ylab = "Residuos",
     pch = 19,
     main = "Suposição de homocedasticidade"
)

#Breusch_Pagan para homocedasticdade
bptest(modelo_betat_cauchit_ftp) #p-value = 0.0001374 heterocedasticidade
## 
##  studentized Breusch-Pagan test
## 
## data:  modelo_betat_cauchit_ftp
## BP = 17.785, df = 2, p-value = 0.0001374
######## Gamlss #######
### Beta ####
gamlss_betap_pf <- gamlss(formula = WINP ~ PF + PlusMinus, family = BEZI, data = dados_regressaop)
## GAMLSS-RS iteration 1: Global Deviance = -161.4236 
## GAMLSS-RS iteration 2: Global Deviance = -329.2529 
## GAMLSS-RS iteration 3: Global Deviance = -330.669 
## GAMLSS-RS iteration 4: Global Deviance = -330.6692
gamlss_betap_pf
## 
## Family:  c("BEZI", "Zero Inflated Beta") 
## Fitting method: RS() 
## 
## Call:  gamlss(formula = WINP ~ PF + PlusMinus, family = BEZI,  
##     data = dados_regressaop) 
## 
## Mu Coefficients:
## (Intercept)           PF    PlusMinus  
##      0.5145      -0.0265       0.1063  
## Sigma Coefficients:
## (Intercept)  
##       3.571  
## Nu Coefficients:
## (Intercept)  
##      -2.197  
## 
##  Degrees of Freedom for the fit: 5 Residual Deg. of Freedom   235 
## Global Deviance:     -330.669 
##             AIC:     -320.669 
##             SBC:     -303.266
summary(gamlss_betap_pf)
## ******************************************************************
## Family:  c("BEZI", "Zero Inflated Beta") 
## 
## Call:  gamlss(formula = WINP ~ PF + PlusMinus, family = BEZI,  
##     data = dados_regressaop) 
## 
## Fitting method: RS() 
## 
## ------------------------------------------------------------------
## Mu link function:  logit
## Mu Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.514484   0.244311   2.106   0.0363 *  
## PF          -0.026499   0.011248  -2.356   0.0193 *  
## PlusMinus    0.106287   0.004552  23.349   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## ------------------------------------------------------------------
## Sigma link function:  log
## Sigma Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  3.57084    0.09504   37.57   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## ------------------------------------------------------------------
## Nu link function:  logit 
## Nu Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -2.1972     0.2152  -10.21   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## ------------------------------------------------------------------
## No. of observations in the fit:  240 
## Degrees of Freedom for the fit:  5
##       Residual Deg. of Freedom:  235 
##                       at cycle:  4 
##  
## Global Deviance:     -330.6692 
##             AIC:     -320.6692 
##             SBC:     -303.266 
## ******************************************************************
coef(gamlss_betap_pf)
## (Intercept)          PF   PlusMinus 
##  0.51448416 -0.02649885  0.10628690
# Resíduos logito #
plot(gamlss_betap_pf, which = 1)

## ******************************************************************
##   Summary of the Randomised Quantile Residuals
##                            mean   =  -0.1698301 
##                        variance   =  0.7175177 
##                coef. of skewness  =  -0.5060405 
##                coef. of kurtosis  =  2.606695 
## Filliben correlation coefficient  =  0.9838817 
## ******************************************************************
shapiro.test(gamlss_betap_pf$residuals) #p-value = 0.05594, normal
## 
##  Shapiro-Wilk normality test
## 
## data:  gamlss_betap_pf$residuals
## W = 0.96679, p-value = 2.193e-05
#Teste de durbin watson para independencia
library(lmtest)
dwtest(gamlss_betap_pf) #p-value = 0.06737
## 
##  Durbin-Watson test
## 
## data:  gamlss_betap_pf
## DW = 1.8508, p-value = 0.1176
## alternative hypothesis: true autocorrelation is greater than 0
#Independência
plot(gamlss_betap_pf$residuals,
     ylab = "Residuos",
     xlab = "Index dos Imovéis", 
     main = "Suposição de independência",
     pch = 19)

#Breusch_Pagan para homocedasticdade
bptest(gamlss_betap_pf) #p-value = 0.0001374 heterocedasticidade
## 
##  studentized Breusch-Pagan test
## 
## data:  gamlss_betap_pf
## BP = 18.652, df = 2, p-value = 8.91e-05
######## Modelos Mistos #######
##### Normal Team ####
misto_normalp_dreb <- gamlss(formula = WINP ~ (re(random = ~1 | TEAM)) +  
                               PlusMinus + DREB, family = NO, data = dados_regressaop) 
## GAMLSS-RS iteration 1: Global Deviance = -436.3104 
## GAMLSS-RS iteration 2: Global Deviance = -436.3104
misto_normalp_dreb
## 
## Family:  c("NO", "Normal") 
## Fitting method: RS() 
## 
## Call:  gamlss(formula = WINP ~ (re(random = ~1 | TEAM)) +  
##     PlusMinus + DREB, family = NO, data = dados_regressaop) 
## 
## Mu Coefficients:
##            (Intercept)  re(random = ~1 | TEAM)               PlusMinus  
##               0.343406                      NA                0.025386  
##                   DREB  
##               0.004065  
## Sigma Coefficients:
## (Intercept)  
##      -2.328  
## 
##  Degrees of Freedom for the fit: 14.43 Residual Deg. of Freedom   225.6 
## Global Deviance:     -436.31 
##             AIC:     -407.444 
##             SBC:     -357.207
coef(misto_normalp_dreb)
##            (Intercept) re(random = ~1 | TEAM)              PlusMinus 
##            0.343405846                     NA            0.025385907 
##                   DREB 
##            0.004064528
summary(misto_normalp_dreb) #AIC:
## ******************************************************************
## Family:  c("NO", "Normal") 
## 
## Call:  gamlss(formula = WINP ~ (re(random = ~1 | TEAM)) +  
##     PlusMinus + DREB, family = NO, data = dados_regressaop) 
## 
## Fitting method: RS() 
## 
## ------------------------------------------------------------------
## Mu link function:  identity
## Mu Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 0.3434058  0.0734368   4.676 5.03e-06 ***
## PlusMinus   0.0253859  0.0009815  25.864  < 2e-16 ***
## DREB        0.0040645  0.0022729   1.788   0.0751 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## ------------------------------------------------------------------
## Sigma link function:  log
## Sigma Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -2.32792    0.04564     -51   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## ------------------------------------------------------------------
## NOTE: Additive smoothing terms exist in the formulas: 
##  i) Std. Error for smoothers are for the linear effect only. 
## ii) Std. Error for the linear terms maybe are not accurate. 
## ------------------------------------------------------------------
## No. of observations in the fit:  240 
## Degrees of Freedom for the fit:  14.43325
##       Residual Deg. of Freedom:  225.5668 
##                       at cycle:  2 
##  
## Global Deviance:     -436.3104 
##             AIC:     -407.4439 
##             SBC:     -357.207 
## ******************************************************************
getSmo(misto_normalp_dreb)
## Linear mixed-effects model fit by maximum likelihood
##   Data: Data 
##   Log-likelihood: 204.9898
##   Fixed: fix.formula 
##   (Intercept) 
## -0.0008263643 
## 
## Random effects:
##  Formula: ~1 | TEAM
##         (Intercept) Residual
## StdDev:   0.0282907 1.024705
## 
## Variance function:
##  Structure: fixed weights
##  Formula: ~W.var 
## Number of Observations: 240
## Number of Groups: 33
#Resíduos
plot(misto_normalp_dreb)

## ******************************************************************
##        Summary of the Quantile Residuals
##                            mean   =  -4.491375e-17 
##                        variance   =  1.004184 
##                coef. of skewness  =  -0.5315828 
##                coef. of kurtosis  =  3.924077 
## Filliben correlation coefficient  =  0.9864969 
## ******************************************************************
shapiro.test(misto_normalp_dreb$residuals) #p-value = 
## 
##  Shapiro-Wilk normality test
## 
## data:  misto_normalp_dreb$residuals
## W = 0.97414, p-value = 0.000228
#Independência
plot(misto_normalp_dreb$residuals,
     ylab = "Residuos",
     xlab = "Index dos Imovéis", 
     main = "Suposição de independência",
     pch = 19)

#Breusch_Pagan para homocedasticdade
bptest(misto_normalp_dreb) #p-value = 
## 
##  studentized Breusch-Pagan test
## 
## data:  misto_normalp_dreb
## BP = 21.659, df = 2, p-value = 1.981e-05
##### Normal Temporada ####
misto_normalp_temp_team <- gamlss(formula = WINP ~ (re(random = ~1 | Numero_temporada)) +  
                                    PlusMinus + DREB + TEAM, family = NO, data = dados_regressaop)
## GAMLSS-RS iteration 1: Global Deviance = -473.5697 
## GAMLSS-RS iteration 2: Global Deviance = -473.5697
misto_normalp_temp_team
## 
## Family:  c("NO", "Normal") 
## Fitting method: RS() 
## 
## Call:  gamlss(formula = WINP ~ (re(random = ~1 | Numero_temporada)) +  
##     PlusMinus + DREB + TEAM, family = NO, data = dados_regressaop) 
## 
## Mu Coefficients:
##                        (Intercept)  re(random = ~1 | Numero_temporada)  
##                           0.346627                                  NA  
##                          PlusMinus                                DREB  
##                           0.024781                            0.004688  
##                 TEAMBoston Celtics                   TEAMBrooklyn Nets  
##                          -0.005755                           -0.103945  
##              TEAMCharlotte Bobcats               TEAMCharlotte Hornets  
##                          -0.249427                            0.163699  
##                  TEAMChicago Bulls             TEAMCleveland Cavaliers  
##                          -0.035875                            0.021331  
##               TEAMDallas Mavericks                  TEAMDenver Nuggets  
##                          -0.021046                           -0.046537  
##                TEAMDetroit Pistons           TEAMGolden State Warriors  
##                          -0.089758                            0.034484  
##                TEAMHouston Rockets                  TEAMIndiana Pacers  
##                           0.011700                           -0.130056  
##                    TEAMLA Clippers            TEAMLos Angeles Clippers  
##                          -0.068940                           -0.030764  
##             TEAMLos Angeles Lakers               TEAMMemphis Grizzlies  
##                           0.012975                            0.018290  
##                     TEAMMiami Heat                 TEAMMilwaukee Bucks  
##                           0.019437                           -0.036961  
##         TEAMMinnesota Timberwolves             TEAMNew Orleans Hornets  
##                          -0.068361                            0.183304  
##           TEAMNew Orleans Pelicans                 TEAMNew York Knicks  
##                          -0.120687                           -0.067320  
##          TEAMOklahoma City Thunder                   TEAMOrlando Magic  
##                          -0.039946                           -0.038859  
##             TEAMPhiladelphia 76ers                    TEAMPhoenix Suns  
##                          -0.029856                            0.056248  
##         TEAMPortland Trail Blazers                TEAMSacramento Kings  
##                          -0.036629                           -0.023561  
##              TEAMSan Antonio Spurs                 TEAMToronto Raptors  
##                          -0.043036                            0.015121  
##                      TEAMUtah Jazz              TEAMWashington Wizards  
##                          -0.046544                           -0.002517  
## Sigma Coefficients:
## (Intercept)  
##      -2.406  
## 
##  Degrees of Freedom for the fit: 35 Residual Deg. of Freedom   205 
## Global Deviance:     -473.57 
##             AIC:     -403.57 
##             SBC:     -281.747
coef(misto_normalp_temp_team)
##                        (Intercept) re(random = ~1 | Numero_temporada) 
##                        0.346626952                                 NA 
##                          PlusMinus                               DREB 
##                        0.024780875                        0.004687656 
##                 TEAMBoston Celtics                  TEAMBrooklyn Nets 
##                       -0.005755339                       -0.103944840 
##              TEAMCharlotte Bobcats              TEAMCharlotte Hornets 
##                       -0.249427359                        0.163699455 
##                  TEAMChicago Bulls            TEAMCleveland Cavaliers 
##                       -0.035874677                        0.021330971 
##               TEAMDallas Mavericks                 TEAMDenver Nuggets 
##                       -0.021046376                       -0.046537067 
##                TEAMDetroit Pistons          TEAMGolden State Warriors 
##                       -0.089758350                        0.034483655 
##                TEAMHouston Rockets                 TEAMIndiana Pacers 
##                        0.011700011                       -0.130055911 
##                    TEAMLA Clippers           TEAMLos Angeles Clippers 
##                       -0.068939682                       -0.030764280 
##             TEAMLos Angeles Lakers              TEAMMemphis Grizzlies 
##                        0.012975042                        0.018290493 
##                     TEAMMiami Heat                TEAMMilwaukee Bucks 
##                        0.019437176                       -0.036960816 
##         TEAMMinnesota Timberwolves            TEAMNew Orleans Hornets 
##                       -0.068361098                        0.183303607 
##           TEAMNew Orleans Pelicans                TEAMNew York Knicks 
##                       -0.120686534                       -0.067319855 
##          TEAMOklahoma City Thunder                  TEAMOrlando Magic 
##                       -0.039945586                       -0.038859328 
##             TEAMPhiladelphia 76ers                   TEAMPhoenix Suns 
##                       -0.029855977                        0.056248385 
##         TEAMPortland Trail Blazers               TEAMSacramento Kings 
##                       -0.036628537                       -0.023561117 
##              TEAMSan Antonio Spurs                TEAMToronto Raptors 
##                       -0.043035574                        0.015121085 
##                      TEAMUtah Jazz             TEAMWashington Wizards 
##                       -0.046544409                       -0.002516683
summary(misto_normalp_temp_team) #AIC:
## ******************************************************************
## Family:  c("NO", "Normal") 
## 
## Call:  gamlss(formula = WINP ~ (re(random = ~1 | Numero_temporada)) +  
##     PlusMinus + DREB + TEAM, family = NO, data = dados_regressaop) 
## 
## Fitting method: RS() 
## 
## ------------------------------------------------------------------
## Mu link function:  identity
## Mu Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 0.346627   0.076655   4.522 1.04e-05 ***
## PlusMinus                   0.024781   0.001032  24.023  < 2e-16 ***
## DREB                        0.004688   0.002300   2.038 0.042839 *  
## TEAMBoston Celtics         -0.005755   0.035805  -0.161 0.872455    
## TEAMBrooklyn Nets          -0.103945   0.041208  -2.522 0.012413 *  
## TEAMCharlotte Bobcats      -0.249427   0.069121  -3.609 0.000387 ***
## TEAMCharlotte Hornets       0.163699   0.094029   1.741 0.083193 .  
## TEAMChicago Bulls          -0.035875   0.039991  -0.897 0.370738    
## TEAMCleveland Cavaliers     0.021331   0.043561   0.490 0.624881    
## TEAMDallas Mavericks       -0.021046   0.038632  -0.545 0.586486    
## TEAMDenver Nuggets         -0.046537   0.038789  -1.200 0.231619    
## TEAMDetroit Pistons        -0.089758   0.059407  -1.511 0.132354    
## TEAMGolden State Warriors   0.034484   0.040998   0.841 0.401271    
## TEAMHouston Rockets         0.011700   0.040066   0.292 0.770568    
## TEAMIndiana Pacers         -0.130056   0.039828  -3.265 0.001281 ** 
## TEAMLA Clippers            -0.068940   0.045216  -1.525 0.128885    
## TEAMLos Angeles Clippers   -0.030764   0.052216  -0.589 0.556392    
## TEAMLos Angeles Lakers      0.012975   0.041296   0.314 0.753693    
## TEAMMemphis Grizzlies       0.018290   0.038643   0.473 0.636485    
## TEAMMiami Heat              0.019437   0.036987   0.526 0.599798    
## TEAMMilwaukee Bucks        -0.036961   0.039210  -0.943 0.346979    
## TEAMMinnesota Timberwolves -0.068361   0.058750  -1.164 0.245944    
## TEAMNew Orleans Hornets     0.183304   0.070151   2.613 0.009641 ** 
## TEAMNew Orleans Pelicans   -0.120687   0.058469  -2.064 0.040267 *  
## TEAMNew York Knicks        -0.067320   0.048063  -1.401 0.162832    
## TEAMOklahoma City Thunder  -0.039946   0.039161  -1.020 0.308916    
## TEAMOrlando Magic          -0.038859   0.045153  -0.861 0.390456    
## TEAMPhiladelphia 76ers     -0.029856   0.040094  -0.745 0.457336    
## TEAMPhoenix Suns            0.056248   0.052393   1.074 0.284267    
## TEAMPortland Trail Blazers -0.036629   0.037850  -0.968 0.334323    
## TEAMSacramento Kings       -0.023561   0.094120  -0.250 0.802582    
## TEAMSan Antonio Spurs      -0.043036   0.038012  -1.132 0.258893    
## TEAMToronto Raptors         0.015121   0.041208   0.367 0.714036    
## TEAMUtah Jazz              -0.046544   0.040055  -1.162 0.246577    
## TEAMWashington Wizards     -0.002517   0.048267  -0.052 0.958467    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## ------------------------------------------------------------------
## Sigma link function:  log
## Sigma Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -2.40554    0.04564   -52.7   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## ------------------------------------------------------------------
## NOTE: Additive smoothing terms exist in the formulas: 
##  i) Std. Error for smoothers are for the linear effect only. 
## ii) Std. Error for the linear terms maybe are not accurate. 
## ------------------------------------------------------------------
## No. of observations in the fit:  240 
## Degrees of Freedom for the fit:  35
##       Residual Deg. of Freedom:  205 
##                       at cycle:  2 
##  
## Global Deviance:     -473.5697 
##             AIC:     -403.5697 
##             SBC:     -281.7473 
## ******************************************************************
getSmo(misto_normalp_temp_team)
## Linear mixed-effects model fit by maximum likelihood
##   Data: Data 
##   Log-likelihood: 236.7848
##   Fixed: fix.formula 
##   (Intercept) 
## -7.596768e-18 
## 
## Random effects:
##  Formula: ~1 | Numero_temporada
##          (Intercept)  Residual
## StdDev: 9.839206e-07 0.9999999
## 
## Variance function:
##  Structure: fixed weights
##  Formula: ~W.var 
## Number of Observations: 240
## Number of Groups: 15
#Resíduos
plot(misto_normalp_temp_team)

## ******************************************************************
##        Summary of the Quantile Residuals
##                            mean   =  -2.035307e-18 
##                        variance   =  1.004184 
##                coef. of skewness  =  -0.4382711 
##                coef. of kurtosis  =  3.51579 
## Filliben correlation coefficient  =  0.9918678 
## ******************************************************************
shapiro.test(misto_normalp_temp_team$residuals) #p-value = 
## 
##  Shapiro-Wilk normality test
## 
## data:  misto_normalp_temp_team$residuals
## W = 0.98337, p-value = 0.006562
#Independência
plot(misto_normalp_temp_team$residuals,
     ylab = "Residuos",
     xlab = "Index dos Imovéis", 
     main = "Suposição de independência",
     pch = 19)

#Breusch_Pagan para homocedasticdade
bptest(misto_normalp_temp_team) #p-value = 
## 
##  studentized Breusch-Pagan test
## 
## data:  misto_normalp_temp_team
## BP = 60.063, df = 34, p-value = 0.003813
##### Beta Team ####
misto_betap_ftp <- gamlss(formula = WINP ~ (re(random = ~1 | TEAM)) +  
                            PlusMinus + PF + BLKA + FTP, family = BEZI, data = dados_regressaop) 
## GAMLSS-RS iteration 1: Global Deviance = -170.0295 
## GAMLSS-RS iteration 2: Global Deviance = -349.6334 
## GAMLSS-RS iteration 3: Global Deviance = -350.6895 
## GAMLSS-RS iteration 4: Global Deviance = -350.6399 
## GAMLSS-RS iteration 5: Global Deviance = -350.6347 
## GAMLSS-RS iteration 6: Global Deviance = -350.6342
misto_betap_ftp
## 
## Family:  c("BEZI", "Zero Inflated Beta") 
## Fitting method: RS() 
## 
## Call:  gamlss(formula = WINP ~ (re(random = ~1 | TEAM)) +  
##     PlusMinus + PF + BLKA + FTP, family = BEZI, data = dados_regressaop) 
## 
## Mu Coefficients:
##            (Intercept)  re(random = ~1 | TEAM)               PlusMinus  
##               0.215798                      NA                0.103393  
##                     PF                    BLKA                     FTP  
##              -0.025465               -0.028687                0.005414  
## Sigma Coefficients:
## (Intercept)  
##       3.661  
## Nu Coefficients:
## (Intercept)  
##      -2.197  
## 
##  Degrees of Freedom for the fit: 13.58 Residual Deg. of Freedom   226.4 
## Global Deviance:     -350.634 
##             AIC:     -323.47 
##             SBC:     -276.196
coef(misto_betap_ftp)
##            (Intercept) re(random = ~1 | TEAM)              PlusMinus 
##            0.215797839                     NA            0.103392931 
##                     PF                   BLKA                    FTP 
##           -0.025464733           -0.028687176            0.005413543
summary(misto_betap_ftp) #AIC:
## ******************************************************************
## Family:  c("BEZI", "Zero Inflated Beta") 
## 
## Call:  gamlss(formula = WINP ~ (re(random = ~1 | TEAM)) +  
##     PlusMinus + PF + BLKA + FTP, family = BEZI, data = dados_regressaop) 
## 
## Fitting method: RS() 
## 
## ------------------------------------------------------------------
## Mu link function:  logit
## Mu Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.215798   0.482300   0.447   0.6550    
## PlusMinus    0.103393   0.004502  22.968   <2e-16 ***
## PF          -0.025465   0.010889  -2.339   0.0202 *  
## BLKA        -0.028687   0.017780  -1.613   0.1080    
## FTP          0.005414   0.004933   1.097   0.2737    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## ------------------------------------------------------------------
## Sigma link function:  log
## Sigma Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  3.66081    0.09514   38.48   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## ------------------------------------------------------------------
## Nu link function:  logit 
## Nu Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -2.1972     0.2152  -10.21   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## ------------------------------------------------------------------
## NOTE: Additive smoothing terms exist in the formulas: 
##  i) Std. Error for smoothers are for the linear effect only. 
## ii) Std. Error for the linear terms maybe are not accurate. 
## ------------------------------------------------------------------
## No. of observations in the fit:  240 
## Degrees of Freedom for the fit:  13.58204
##       Residual Deg. of Freedom:  226.418 
##                       at cycle:  6 
##  
## Global Deviance:     -350.6342 
##             AIC:     -323.4701 
##             SBC:     -276.1959 
## ******************************************************************
getSmo(misto_betap_ftp)
## Linear mixed-effects model fit by maximum likelihood
##   Data: Data 
##   Log-likelihood: -374.7157
##   Fixed: fix.formula 
##   (Intercept) 
## -0.0007885399 
## 
## Random effects:
##  Formula: ~1 | TEAM
##         (Intercept)  Residual
## StdDev:  0.07091602 0.9627084
## 
## Variance function:
##  Structure: fixed weights
##  Formula: ~W.var 
## Number of Observations: 240
## Number of Groups: 33
#Resíduos
plot(misto_betap_ftp)

## ******************************************************************
##   Summary of the Randomised Quantile Residuals
##                            mean   =  -0.1737727 
##                        variance   =  0.7273011 
##                coef. of skewness  =  -0.5256851 
##                coef. of kurtosis  =  2.742173 
## Filliben correlation coefficient  =  0.9845265 
## ******************************************************************
shapiro.test(misto_betap_ftp$residuals) #p-value = 
## 
##  Shapiro-Wilk normality test
## 
## data:  misto_betap_ftp$residuals
## W = 0.96833, p-value = 3.504e-05
#Independência
plot(misto_betap_ftp$residuals,
     ylab = "Residuos",
     xlab = "Index dos Imovéis", 
     main = "Suposição de independência",
     pch = 19)

#Breusch_Pagan para homocedasticdade
bptest(misto_betap_ftp) #p-value = 
## 
##  studentized Breusch-Pagan test
## 
## data:  misto_betap_ftp
## BP = 19.939, df = 4, p-value = 0.0005133
##### Beta Temp ####
misto_betap_temp <- gamlss(formula = WINP ~ (re(random = ~1 | Numero_temporada)) +  
                                PlusMinus + PF, family = BEZI, data = dados_regressaop) 
## GAMLSS-RS iteration 1: Global Deviance = -161.4236 
## GAMLSS-RS iteration 2: Global Deviance = -329.2529 
## GAMLSS-RS iteration 3: Global Deviance = -330.669 
## GAMLSS-RS iteration 4: Global Deviance = -330.6692
misto_betap_temp
## 
## Family:  c("BEZI", "Zero Inflated Beta") 
## Fitting method: RS() 
## 
## Call:  gamlss(formula = WINP ~ (re(random = ~1 | Numero_temporada)) +  
##     PlusMinus + PF, family = BEZI, data = dados_regressaop) 
## 
## Mu Coefficients:
##                        (Intercept)  re(random = ~1 | Numero_temporada)  
##                             0.5145                                  NA  
##                          PlusMinus                                  PF  
##                             0.1063                             -0.0265  
## Sigma Coefficients:
## (Intercept)  
##       3.571  
## Nu Coefficients:
## (Intercept)  
##      -2.197  
## 
##  Degrees of Freedom for the fit: 4 Residual Deg. of Freedom   236 
## Global Deviance:     -330.669 
##             AIC:     -322.669 
##             SBC:     -308.747
coef(misto_betap_temp)
##                        (Intercept) re(random = ~1 | Numero_temporada) 
##                         0.51448416                                 NA 
##                          PlusMinus                                 PF 
##                         0.10628690                        -0.02649885
summary(misto_betap_temp) #AIC:
## ******************************************************************
## Family:  c("BEZI", "Zero Inflated Beta") 
## 
## Call:  gamlss(formula = WINP ~ (re(random = ~1 | Numero_temporada)) +  
##     PlusMinus + PF, family = BEZI, data = dados_regressaop) 
## 
## Fitting method: RS() 
## 
## ------------------------------------------------------------------
## Mu link function:  logit
## Mu Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.514484   0.244311   2.106   0.0363 *  
## PlusMinus    0.106287   0.004552  23.349   <2e-16 ***
## PF          -0.026499   0.011248  -2.356   0.0193 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## ------------------------------------------------------------------
## Sigma link function:  log
## Sigma Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  3.57084    0.09504   37.57   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## ------------------------------------------------------------------
## Nu link function:  logit 
## Nu Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -2.1972     0.2152  -10.21   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## ------------------------------------------------------------------
## NOTE: Additive smoothing terms exist in the formulas: 
##  i) Std. Error for smoothers are for the linear effect only. 
## ii) Std. Error for the linear terms maybe are not accurate. 
## ------------------------------------------------------------------
## No. of observations in the fit:  240 
## Degrees of Freedom for the fit:  4
##       Residual Deg. of Freedom:  236 
##                       at cycle:  4 
##  
## Global Deviance:     -330.6692 
##             AIC:     -322.6692 
##             SBC:     -308.7466 
## ******************************************************************
getSmo(misto_betap_temp)
## Linear mixed-effects model fit by maximum likelihood
##   Data: Data 
##   Log-likelihood: -376.032
##   Fixed: fix.formula 
##  (Intercept) 
## 4.471334e-12 
## 
## Random effects:
##  Formula: ~1 | Numero_temporada
##          (Intercept)  Residual
## StdDev: 8.256872e-06 0.9485917
## 
## Variance function:
##  Structure: fixed weights
##  Formula: ~W.var 
## Number of Observations: 240
## Number of Groups: 15
#Resíduos
plot(misto_betap_temp)

## ******************************************************************
##   Summary of the Randomised Quantile Residuals
##                            mean   =  -0.1821301 
##                        variance   =  0.7877213 
##                coef. of skewness  =  -0.907402 
##                coef. of kurtosis  =  4.936006 
## Filliben correlation coefficient  =  0.9717185 
## ******************************************************************
shapiro.test(misto_betap_temp$residuals) #p-value = 
## 
##  Shapiro-Wilk normality test
## 
## data:  misto_betap_temp$residuals
## W = 0.94588, p-value = 8.96e-08
#Independência
plot(misto_betap_temp$residuals,
     ylab = "Residuos",
     xlab = "Index dos Imovéis", 
     main = "Suposição de independência",
     pch = 19)

#Breusch_Pagan para homocedasticdade
bptest(misto_betap_temp) #p-value = 
## 
##  studentized Breusch-Pagan test
## 
## data:  misto_betap_temp
## BP = 18.652, df = 2, p-value = 8.91e-05